MYSQL=/usr/local/mysql
CC=gcc
TLIB=../lib/libtlib.a
TFCGILIB=../lib/libtfcgilib.a
OBJS=tlib_str.o tlib_dbf.o tlib_mail.o tlib_ini.o tlib_tools.o tlib_html.o \
	  tlib_cfg.o tlib_log.o tlib_shm.o tlib_lck.o tlib_mem.o tlib_ip_limit.o \
	  tlib_sock.o tlib_dirty_check.o  tlib_warn.o \
		tlib_warn_log.o tlib_report.o

$(TLIB):
#	gcc -fPIC -g -c tlib_db/tlib_db.c -I. -Itlib_db -Itlib_log -I$(MYSQL)/include 
	gcc -fPIC -g -c tlib_mem/tlib_mem.c -I. -Itlib_mem
	gcc -fPIC -g -c tlib_str/tlib_str.c -I. -Itlib_str
	gcc -fPIC -g -c tlib_dbf/tlib_dbf.c -I. -Itlib_dbf -Itlib_str
	gcc -fPIC -g -c tlib_ini/tlib_ini.c -I. -Itlib_ini -Itlib_str
	gcc -fPIC -g -c tlib_mail/tlib_mail.c -I. -Itlib_mail -Itlib_str -Itlib_sock
#	gcc -fPIC -g -c tlib_session/tlib_session.c -I. -Itlib_session -I../include -I/usr/local/mysql/include
#	gcc -fPIC -g -c tlib_session_tcp/tlib_session_tcp.c  -I. -Itlib_session_tcp -I../include
#	gcc -fPIC -g -c tlib_session_shm/tlib_session_shm.c  -I. -Itlib_session_shm -I../include
	gcc -fPIC -g -c tlib_tools/tlib_tools.c -I. -Itlib_tools
	gcc -fPIC -g -c tlib_html/tlib_html.c -I. -Itlib_html
	gcc -fPIC -g -c tlib_cfg/tlib_cfg.c -I. -Itlib_cfg -Itlib_str
	gcc -fPIC -g -c tlib_log/tlib_log.c -I. -Itlib_log
	gcc -fPIC -g -c tlib_shm/tlib_shm.c -I. -Itlib_shm -Itlib_ini
	gcc -fPIC -g -c tlib_lck/tlib_lck.c -I. -Itlib_lck
#	gcc -fPIC -g -c  tlib_cgi/tlib_cgi.c -I. -Itlib_cgi -I../include
	gcc -fPIC -g -c tlib_ip_limit/tlib_ip_limit.c -I. -Itlib_ip_limit 
	gcc -fPIC -g -c tlib_dirty_check/tlib_dirty_check.c -I. -Itlib_dirty_check
#	cp -f tlib_net/net/* /usr/include/net
#	cp -f tlib_net/netinet/* /usr/include/netinet
#	gcc -fPIC -g -c tlib_net/tlib_net.c -Iinclude -I. -Itlib_net
	gcc -fPIC -g -c tlib_sock/tlib_sock.c -Iinclude -I. -Itlib_sock 
	gcc -fPIC -g -c tlib_warn/tlib_warn.c -Iinclude -I. -Itlib_warn
	gcc -fPIC -g -c tlib_warn_log/tlib_warn_log.c -I. -Itlib_warn_log
	gcc -fPIC -g -c tlib_report/tlib_report.c -I. -Itlib_report
	ar q $(TLIB) $(OBJS)
	
$(TFCGILIB):
#	gcc -fPIC -g -c -DFASTCGI tlib_db/tlib_db.c -I. -Itlib_db -Itlib_log -I$(MYSQL)/include 
	gcc -fPIC -g -c -DFASTCGI tlib_mem/tlib_mem.c -I. -Itlib_mem
	gcc -fPIC -g -c -DFASTCGI tlib_str/tlib_str.c -I. -Itlib_str
	gcc -fPIC -g -c -DFASTCGI tlib_dbf/tlib_dbf.c -I. -Itlib_dbf -Itlib_str
	gcc -fPIC -g -c -DFASTCGI tlib_ini/tlib_ini.c -I. -Itlib_ini -Itlib_str
	gcc -fPIC -g -c -DFASTCGI tlib_mail/tlib_mail.c -I. -Itlib_mail -Itlib_str -Itlib_sock
#	gcc -fPIC -g -c -DFASTCGI tlib_session/tlib_session.c -I. -Itlib_session -I../include -I/usr/local/mysql/include
#	gcc -fPIC -g -c -DFASTCGI tlib_session_tcp/tlib_session_tcp.c  -I. -Itlib_session_tcp -I../include
#	gcc -fPIC -g -c -DFASTCGI tlib_session_shm/tlib_session_shm.c  -I. -Itlib_session_shm -I../include
	gcc -fPIC -g -c -DFASTCGI tlib_tools/tlib_tools.c -I. -Itlib_tools
	gcc -fPIC -g -c -DFASTCGI tlib_html/tlib_html.c -I. -Itlib_html
	gcc -fPIC -g -c -DFASTCGI tlib_cfg/tlib_cfg.c -I. -Itlib_cfg -Itlib_str
	gcc -fPIC -g -c -DFASTCGI tlib_log/tlib_log.c -I. -Itlib_log
	gcc -fPIC -g -c -DFASTCGI tlib_shm/tlib_shm.c -I. -Itlib_shm -Itlib_ini
	gcc -fPIC -g -c -DFASTCGI tlib_lck/tlib_lck.c -I. -Itlib_lck
#	gcc -fPIC -g -c -DFASTCGI tlib_cgi/tlib_cgi.c -I. -Itlib_cgi -I../include
	gcc -fPIC -g -c -DFASTCGI tlib_ip_limit/tlib_ip_limit.c -I. -Itlib_ip_limit 
	gcc -fPIC -g -c -DFASTCGI tlib_dirty_check/tlib_dirty_check.c -I. -Itlib_dirty_check
	gcc -fPIC -g -c -DFASTCGI tlib_warn/tlib_warn.c -Iinclude -I. -Itlib_warn
	gcc -fPIC -g -c -DFASTCGI tlib_warn_log/tlib_warn_log.c -I. -Itlib_warn_log
#	cp -f tlib_net/net/* /usr/include/net
#	cp -f tlib_net/netinet/* /usr/include/netinet
#	gcc -fPIC -g -c -DFASTCGI tlib_net/tlib_net.c -Iinclude -I. -Itlib_net
	gcc -fPIC -g -c -DFASTCGI tlib_sock/tlib_sock.c -Iinclude -I. -Itlib_sock 
	ar q $(TFCGILIB) $(OBJS)	

all:$(TLIB) $(TFCGILIB) installh

installh:
	cp -f ./tlib_com.h ../include
	cp -f ./tlib_all.h ../include
	cp -f tlib_str/tlib_str.h ../include
	cp -f tlib_dbf/tlib_dbf.h ../include
	cp -f tlib_ini/tlib_ini.h ../include
	cp -f tlib_mail/tlib_mail.h ../include
	cp -f tlib_session/tlib_session.h ../include	
	cp -f tlib_session_tcp/tlib_session_tcp.h ../include
	cp -f tlib_session_shm/tlib_session_shm.h ../include
	cp -f tlib_tools/tlib_tools.h ../include
	cp -f tlib_html/tlib_html.h ../include
	cp -f tlib_cfg/tlib_cfg.h ../include
	cp -f tlib_log/tlib_log.h ../include
	cp -f tlib_shm/tlib_shm.h ../include
	cp -f tlib_lck/tlib_lck.h ../include
	cp -f tlib_cgi/tlib_cgi.h ../include
	cp -f tlib_mem/tlib_mem.h ../include
	cp -f tlib_db/tlib_db.h ../include
	cp -f tlib_ip_limit/tlib_ip_limit.h ../include
	cp -f tlib_net/tlib_net.h ../include
	cp -f tlib_sock/tlib_sock.h ../include
	cp -f tlib_dirty_check/tlib_dirty_check.h ../include
	cp -f tlib_warn/tlib_warn.h ../include
	cp -f tlib_warn_log/tlib_warn_log.h ../include
	cp -f tlib_report/tlib_report.h ../include

clean: 
	rm -rf $(TLIB) $(TFCGILIB)
	rm *.o

install:
	cp *.a /usr/local/build/lib
	cp -f ../include/*.h /usr/local/build/include